package com.gzyj.jtt808.v2013.protocol;

import com.gzyj.jtt808.utils.HexBytesUtil;
import com.gzyj.jtt808.v2013.enums.BusinessDataType;
import io.netty.buffer.ByteBuf;
import lombok.Data;

import java.io.Serializable;
import java.nio.charset.Charset;
import com.gzyj.jtt808.v2013.Package;

@Data
public class JTT808_0x0102 extends Package implements Serializable {

    private String Code;//鉴权码

    public JTT808_0x0102() {
        super(BusinessDataType.终端鉴权.getCode());
    }

    @Override
    public void encodeImpl(ByteBuf buf) {
        buf.writeBytes(Code.getBytes(Charset.forName("GBK")));
    }

    @Override
    public JTT808_0x0102 decodeImpl(ByteBuf buf) {
        byte[] temp = HexBytesUtil.readByOffset(buf, buf.readableBytes());
        this.Code = new String(temp, Charset.forName("GBK"));


        return this;
    }


}
